package com.hf.wujian;

import com.hf.wujian.annotation.Dispatch;
import com.hf.wujian.utils.AnnotationUtils;
import com.hf.wujian.utils.FileUtils;
import java.io.File;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;

public class Main {

    //服务器监听接口
    private static final int portNumber = 10086;

    public static void main(String[] args) {
        //读取配置文件----------------


        //扫描所有注解----------------
        //获取com包目录
        String classRootPath = Main.class.getClass().getResource("/").getPath();
        File file = new File(classRootPath + "/" + "com");
        //扫描目录下所有.class文件
        List<Class> classes = new ArrayList<>();
        FileUtils.scanFileToClassList(classes,file,file.getName());
        //获取所有调度器的map
        Map<Integer, Class> dispatchs = AnnotationUtils.getAnnotationClassByMap(classes,Dispatch.class,"command");

        //启动服务器----------------
        DispatchServer dispatchServer = new DispatchServer(portNumber,dispatchs);
        dispatchServer.start();
    }
}
